def sortColumns(matrix): # DO NOT modify this line
    a = matrix
    L = len(matrix)
    l = len(matrix[0])
    list1 = []
    for i in range(l):
        list1.clear()
        for j in range(L):
            list1.append(matrix[j][i])
        list1.sort()
        for j in range(L):
            a[j][i]=list1[j]
    # TODO: add your code here
    return a# You can modify or delete this line

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===